<nav class="navbar-default navbar-static-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav metismenu" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element"> 
                    <span><img alt="image" class="img-circle" src="img/profile_small.jpg" /></span>
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">David Williams</strong>
                             </span> <span class="text-muted text-xs block">Art Director <b class="caret"></b></span> </span>  </a>
                        <ul class="dropdown-menu animated fadeInRight m-t-xs">
                            <li><a href="profile.html">Profile</a></li>
                            <li><a href="contacts.html">Contacts</a></li>
                            <li><a href="mailbox.html">Mailbox</a></li>
                            <li class="divider"></li>
                            <li><a href="login.html">Logout</a></li>
                        </ul>
                    </div>
                    <div class="logo-element">
                        IN+
                    </div>
                </li>
                <?php foreach ($nodes as $key => $node): ?>
                    <li>
                        <a href="#"><i class="fa fa-th-large"></i> <span class="nav-label"><?php echo $node['title'] ?></span> <span class="fa arrow"></span></a>
                        <ul class="nav nav-second-level collapse">
                            <?php if ($node['child']): ?>
                            <?php foreach ($node['child'] as $k => $v): ?>
                                <li <?php if ($segment_string == $v['name']){ ?>class="active"<?php } ?>><a href="<?php echo site_url($v['name']) ?>"><?php echo $v['title'] ?></a></li>
                            <?php endforeach ?>
                            <?php endif ?>
                        </ul>
                    </li>
                <?php endforeach ?>
            </ul>

        </div>
    </nav>

    <script type="text/javascript">
        $(function(){
            var main_menu = $('.active').parent().parent();
            console.log(main_menu);
            // main_menu.addClass('active');
            main_menu.attr('class','active');
        });
    </script>